<template>
	<view class="mainBg h100 container">
		<navbar title="我的优惠" />
		<view class="list">
			<view class="col">
				<view class="item" v-for="(item,index) in list" :key="item.id">
					<view class="upper">
						<view class="left">
							<view class="price ">
								<text>￥</text> {{item.reachAmount}}
							</view>
							<view class="text">
								{{item.couponInfo.name}}
								<text v-if="item.end_date">有效期至{{item.end_date}}</text>
							</view>
						</view>
						<view class="right">
							<view class="btn" v-if="item.status == 0" @click="goCourse">
								立即使用
							</view>
							<view class="btn overdue" v-if="item.status == 1">
								已使用
							</view>
							<view class="btn overdue" v-if="item.status == 2">
								已过期
							</view>
						</view>
					</view>
					<view class="tips">
						新用户专享
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				this.$post("/coupon/couponList").then(res => {
						if(res.code == 200)
						{
							this.list = res.data
						}
				})
			},
			goCourse(){
				uni.navigateTo({
					url:'/pages/index/list/course'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #35CBAD;
	}

	.list {

		.col {
			padding: 10rpx;

			.item {
				background-color: #fff;
				box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.05);
				border-radius: 8rpx;
				padding: 30rpx 40rpx;

				.upper {
					display: flex;
					justify-content: space-between;

					.left {
						display: flex;
						align-items: center;
					}

					.price {
						color: $assist-color2;
						font-weight: bold;
						font-size: 96rpx;
						line-height: 1;

						text {
							font-size: 40rpx;
						}
					}

					.text {
						font-size: 28rpx;

						text {
							display: block;
							font-size: 24rpx;
							color: #999;
						}
					}

					.btn {
						width: 150rpx;
						line-height: 56rpx;
						font-weight: bold;
						color: #fff;
						text-align: center;
						background-color: $assist-color2;
						border-radius: 100px;
						font-size: 24rpx;
					}

					.overdue {
						background-color: #e2e2e2;
					}
				}

				.tips {
					font-size: 24rpx;
					color: #999;
					margin-top: 30rpx;
				}
			}
		}
	}
</style>